package com.huatai.vba.execute.handler;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

import com.alibaba.druid.support.json.JSONUtils;
import com.huatai.vba.dal.model.VbaFileHandler;

@Service
public class ExecuteFactory {

	@Autowired
	private ApplicationContext applicationContext;

	@Autowired
	private ExecuteService copyFileExecuteService;

	@Autowired
	private ExecuteService createFileExecuteService;

	@Autowired
	private ExecuteService deleteFileExecuteService;

	public ExecuteService getExecuteService(VbaFileHandler handler) {
		if ("1".equals(handler.getHandlerType())) {
			return copyFileExecuteService;
		} else if ("2".equals(handler.getHandlerType())) {
			return createFileExecuteService;
		} else if ("3".equals(handler.getHandlerType())) {
			return deleteFileExecuteService;
		} else if ("4".equals(handler.getHandlerType())) {
			Map<String, String> map = (Map<String, String>) JSONUtils.parse(handler.getHandlerProperties());
			return (ExecuteService) applicationContext.getBean("icbcIntefaceCreateExecuteService");
		}
		return null;
	}

}
